import { useEffect, useState } from 'react';
import { apiGetUserInfo } from '@/pages/_server/_api/Mine/apiGetUserInfo';
import { UserInfo_Web } from '@/pages/_server/_class/Mine/UserInfo';
export type listArrType = typeof oriListArr;
const oriListArr = [
    { iconCode: <>&#xe640;</>, title: '我的订单', url: 'pages/MyOrder/MyOrder' },
    { iconCode: <>&#xe63b;</>, title: '我的收藏', url: 'pages/MyCollection/MyCollection' },
    { iconCode: <>&#xe646;</>, title: '活动', url: 'pages/MyActivities/MyActivities' },
    { iconCode: <>&#xe60a;</>, title: '消息', url: 'pages/MessageNotification/MessageNotification' },
    {
        iconCode: <>&#xe641;</>,
        title: '实名认证',
        url: 'pages/RealNameAuthentication/RealNameAuthentication',
    },
    { iconCode: <>&#xe764;</>, title: '我的转赠', url: '' },
    { iconCode: <>&#xe694;</>, title: '艺术家入驻', url: 'pages/ArtistsSettledIn/ArtistsSettledIn' },
    { iconCode: <>&#xe608;</>, title: '联系我们', url: 'pages/ContactUs/ContactUs' },
    { iconCode: <>&#xe71a;</>, title: '退出当前账号', url: 'pages/Login/Login' },
];
export const useMine = () => {
    const [listArr, setListArr] = useState(oriListArr);
    const [userInfo, setUserInfo] = useState({
        nickName: '未登录',
        avatarUrl: '',
        contractAddress: '请先登录',
    } as Partial<UserInfo_Web>);

    useEffect(() => {
        (async function getUserInfo() {
            let res = await apiGetUserInfo();
            if (!res) return;
            setUserInfo(res.data);
            let newArr;
            if (res.data.isRegisteredArtist) {
                debugger;
                newArr = oriListArr.filter((item, index) => {
                    if (index !== 6) return item;
                });
                setListArr(newArr);
            }
        })();
    }, []);

    return {
        listArr,
        userInfo,
    };
};
